package com.kadron.library.embed;

import java.io.Serializable;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

import com.kadron.dao.KEmbedDAO;
import com.kadron.datamodel.KDataModel;
import com.kadron.datamodel.KEmbedListModelDataProvider;
import com.kadron.manager.KMessageManager;

@AutoCreate
@Scope(ScopeType.PAGE)
@Name("kEmbedListViewManager")
public class KEmbedListViewManager extends KMessageManager implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2066556966063117603L;

	private KDataModel embedList;
	private KEmbedListModelDataProvider dataProvider;
	private KEmbedListSearch search = new KEmbedListSearch();
	
	@In
	private KEmbedDAO embedDAO;
	
	@Create
	public void init() {
		search();
	}
	
	public void search() {
		if (dataProvider == null) {
			dataProvider = new KEmbedListModelDataProvider(null, search, embedDAO);			
		} else {
			dataProvider.setSearch(search);
		}
		embedList = new KDataModel(dataProvider);		
	}
	
	public void reset() {
		search = new KEmbedListSearch();
		dataProvider = new KEmbedListModelDataProvider(null,search, embedDAO);
		embedList = new KDataModel(dataProvider);		
	}
	
	public KDataModel getEmbedList() {
		return embedList;
	}

	public KEmbedListSearch getSearch() {
		return search;
	}
	
}
